package com.hechao;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

public class T05 {

	private List<Student> list;
	
	private StudentManage manage;
	/**
	 * 初始化学生
	 */
	@Before
	public void initStudent() {
		
		list = new ArrayList<Student>();
		
		Student s01 = new Student(10, "张无忌", 88);
		Student s02 = new Student(20, "张三丰", 77);
		Student s03 = new Student(11, "周芷若", 33);
		
		list.add(s01);
		list.add(s02);
		list.add(s03);
		
		manage = new StudentManage(list);
		
	}
	
	@Test
	public void addStudent() throws Exception {
		
		initStudent();
		Student s = new Student (40, "李世民", 55);
		
		manage.addStudent(s);
		
		for (Student student : list) {
			System.out.println(student);
		}
	}
	
	@Test
	public void findStudentsByName() throws Exception {
		
		List<Student> students = manage.findStudentsByName('周');
		
		for (Student student : students) {
			System.out.println(student);
		}
		
	}
}
